<template>
  <view>
    <c-navBar title="修改密码"></c-navBar>
  </view>
  <CForm
    @submit="submit"
    :formRules="formRules"
    v-model:formData="formData"
    :formList="formList"
  ></CForm>
</template>

<script setup>
import { ref } from "vue"
import CForm from "@/components/CForm/CForm.vue"
import { savePassword } from "@/apis/user.js"
import { modifyInfoForm } from "./data"
const { formField, formList, formRules } = modifyInfoForm
const defaultData = JSON.parse(JSON.stringify(formField))
let formData = ref(JSON.parse(JSON.stringify(formField)))
const submit = () => {
  savePassword(formData.value).then((res) => {
    uni.showSuccessToast("修改成功!")
    formData.value = JSON.parse(JSON.stringify(defaultData))
    setTimeout(() => {
      uni.navigateBack({
        delta: 1
      })
    }, 1500)
  })
}
</script>

<style></style>
